import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm;

import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;
import java.security.Key;
import io.jsonwebtoken.*;
import java.util.Date;     

/**
 * Created by Administrator on 2016/9/5.
 */
public class test {

    public static void main(String[] args) {
//        String string = encode("【通知】各位英语老师:  明天(9月6日)下午第三节课召开新学期英语教研组教研工作会议(地点: 二号楼五楼物理实验室)，传达学校新学期教研教学工作精神，布署英语教研组新学期工作计划安排。请您届时参加会议! 不得缺席! 谢谢!（英语教研组 9月5日）");
//        String utfStr = new String(string.getBytes(),"UTF-8");

//        System.out.print(string);
    }

//    static final Pattern reUnicode = Pattern.compile("\\\\u([0-9a-zA-Z]{4})");
//
//    public static String decode1(String s) {
//        Matcher m = reUnicode.matcher(s);
//        StringBuffer sb = new StringBuffer(s.length());
//        while (m.find()) {
//            m.appendReplacement(sb,
//                    Character.toString((char) Integer.parseInt(m.group(1), 16)));
//        }
//        m.appendTail(sb);
//        return sb.toString();
//    }
//
//    public static String encode(String s) {
//        StringBuilder sb = new StringBuilder(s.length() * 3);
//        for (char c : s.toCharArray()) {
//            if (c < 256) {
//                sb.append(c);
//            } else {
//                sb.append("\\u");
//                sb.append(Character.forDigit((c >>> 12) & 0xf, 16));
//                sb.append(Character.forDigit((c >>> 8) & 0xf, 16));
//                sb.append(Character.forDigit((c >>> 4) & 0xf, 16));
//                sb.append(Character.forDigit((c) & 0xf, 16));
//            }
//        }
//        return sb.toString();
//    }


    //Sample method to construct a JWT

//    private String createJWT(String id, String issuer, String subject, long ttlMillis) {
//
//        //The JWT signature algorithm we will be using to sign the token
//        SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
//
//        long nowMillis = System.currentTimeMillis();
//        Date now = new Date(nowMillis);
//
//        //We will sign our JWT with our ApiKey secret
//        byte[] apiKeySecretBytes = DatatypeConverter.parseBase64Binary(apiKey.getSecret());
//        Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName());
//
//        //Let's set the JWT Claims
//        JwtBuilder builder = Jwts.builder().setId(id)
//                .setIssuedAt(now)
//                .setSubject(subject)
//                .setIssuer(issuer)
//                .signWith(signatureAlgorithm, signingKey);
//
//        //if it has been specified, let's add the expiration
//        if (ttlMillis >= 0) {
//            long expMillis = nowMillis + ttlMillis;
//            Date exp = new Date(expMillis);
//            builder.setExpiration(exp);
//        }
//
//        //Builds the JWT and serializes it to a compact, URL-safe string
//        return builder.compact();
//    }
}
